package net.zabuchy.iteration.entity;

import java.io.Serializable;
import javax.persistence.*;

import net.zabuchy.issue.entity.Issue;
import net.zabuchy.project.entity.Project;

import java.util.Date;
import java.util.HashSet;
import java.util.Set;

@Entity
@Table(name="iteration", catalog="quickstart")
public class Iteration implements Serializable {
	
	private static final long serialVersionUID = 1L;
	
	private int iterationId;
	private byte actualIteration;
	private int customerId;
	private Date endDate;
	private int iterationNumber;
	private Project project;
	private Date startDate;
	private Set<Issue> issues = new HashSet<Issue>(0);
	
    public Iteration() {
    }
    
    @Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	@Column(name="ITERATION_ID", unique=true, nullable = false)
	public int getIterationId() {
		return this.iterationId;
	}

	public void setIterationId(int iterationId) {
		this.iterationId = iterationId;
	}
	
	@Column(name="ACTUAL_ITERATION")
	public byte getActualIteration() {
		return this.actualIteration;
	}

	public void setActualIteration(byte actualIteration) {
		this.actualIteration = actualIteration;
	}

	@Column(name="CUSTOMER_ID", nullable = false, length=11)
	public int getCustomerId() {
		return this.customerId;
	}

	public void setCustomerId(int customerId) {
		this.customerId = customerId;
	}

	@Column(name="END_DATE", nullable = false)
	public Date getEndDate() {
		return this.endDate;
	}

	public void setEndDate(Date endDate) {
		this.endDate = endDate;
	}

	@Column(name="ITERATION_NUMBER", nullable = false)
	public int getIterationNumber() {
		return this.iterationNumber;
	}

	public void setIterationNumber(int iterationNumber) {
		this.iterationNumber = iterationNumber;
	}

	@Column(name="START_DATE", nullable = false)
	public Date getStartDate() {
		return this.startDate;
	}

	public void setStartDate(Date startDate) {
		this.startDate = startDate;
	}
	
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "PROJECT_ID", nullable = false)
	public Project getProject() {
		return project;
	}
	
	public void setProject(Project project) {
		this.project = project;
	}
	
	@OneToMany(fetch = FetchType.LAZY, mappedBy = "iteration")
	public Set<Issue> getIssues() {
		return issues;
	}
	
	public void setIssues(Set<Issue> issues) {
		this.issues = issues;
	}
	

}